<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, width=device-width">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta content="black" name="apple-mobile-web-app-status-bar-style">
	<meta name="format-detection" content="telephone=no">
	<meta content="telephone=no" name="format-detection">
	<meta http-equiv="X-UA-Compatible" content="chrome=1,IE=edge" />
	<link rel="stylesheet" media="screen and (max-width:900px)" href="/assets/stylesheets/style_wap.css" type="text/css" />
	<link rel="stylesheet" media="screen and (min-width:900px)" href="/assets/stylesheets/style_pc.css" type="text/css" />
	<title>现金积分提现</title>
</head>
<body>
	<!-- 前端嵌套写法，仅供前端使用，首页有完整代码 -->
	<div class="topline" id="J_topline" data-til="现金积分转账给其他用户">
		<nav th:replace="hjh/include::menuV"></nav>
	</div>
	<div class="vipreg tixian content">
		<p class="fgtil">现金积分提现</p>
		<div class="formline">
			<div class="fline"><p class="ado">可提金额：</p><p class="flinete"><span class="fc fsa" th:text="${#numbers.formatDecimal(cashPointsTotal * 0.01, 1, 2)}"></span>元</p></div>
			<div class="fline">
				<p class="ado">提现账号：</p>
				<select class="J_select ctrol ctrol_select" data-target="taocan" id="J_cardId">
					<option  th:each="data:${bankCardList}" th:value="${data.id}" th:text="${data.cardNumber + ' '+ data.bankName}" th:attr="card-id=${data.id}"></option>
				</select>
			<p class="flineflt">如果还没有提现账号，请前往个人中心<a href="/bankcard_list" class="fc">绑定银行卡</a></p>
			</div>
			<div class="fline">
				<p class="ado">提现金额：</p>
				<input class="J_ctrol ctrol" data-type="number" type="number" placeholder="最低100元且是100的整数" id="J_amount" min="100">
				<br /><p class="flineflt">提现收取<a href="" class="fc">5%</a>手续费，T+1个工作日到账。</p>
			</div>

			<div class="fline"><p class="ado">交易密码：</p><input class="J_ctrol ctrol" data-target="edu" type="password" placeholder="" name="" id="J_payPwd">
			</div>
			<div class="fline linea"><a href="javascript:;" class="btn fbtm" id="J_btn">提交</a></div>
		</div>
	</div>
	<nav th:replace="hjh/include::bottomV"></nav>
	<script language="javascript" type="text/javascript" src="/assets/javascript/jquery-2.1.4.min.js"></script>
	<script language="javascript" type="text/javascript" src="/assets/javascript/func.js"></script>
	<script type="text/javascript">
		$(function(){
			var J_btn = $('#J_btn'),
				isajax = false, // 设置开关
				data = {"taocan":1,"vip":1};
			J_btn.click(function(){
				data.cardId=$("#J_cardId").val();
				data.amount=$("#J_amount").val();
				data.payPwd=$("#J_payPwd").val();
				if(isajax){return false;}

				if(!data.amount){
					errormsg($('#J_amount'),'请输入要提现金额');
					return;
				};
				if(data.amount < 100){
					errormsg($('#J_amount'),'提现金额不能小于100元');
					return;
				}
				if((data.amount % 100) != 0){
					errormsg($('#J_amount'),'提现金额需是100的整数');
					return;
				}
				if(!data.payPwd){
					errormsg($('#J_payPwd'),'请输入交易密码');
					return;
				};
				//ajax提交数据
				//alert('提交的数据：'+JSON.stringify(data));
				isajax = true;
				J_btn.html("正在提交···");
				$.ajax({
					type: "POST",
					url: "/cash_withdraw?v="+(new Date().getTime()),
					data: JSON.stringify(data),
					dataType: "json",
					contentType:"application/json",
					success: function(res){
						if(res.code==0){
							// 提交成功
							alert('提现申请成功');
							window.location.href = window.location.href;
						}else{
							if(res.code==101){
								errormsg($('#J_amount'),res.msg);
							}else{
								errormsg($('#J_payPwd'),res.msg);
							}
							J_btn.html("提交");
						};
					},
					complete:function(){
						isajax = false;
					}
				});

			});
		});
	</script>
</body>
</html>
